#include <iostream>

using std::cout;
using std::cin;
using std::endl;

// std::gregorian::date 类在这个头文件中。
#include <boost/date_time/gregorian/gregorian.hpp>

// c++11 之后新增的， 使用using代替typedef
using date = boost::gregorian::date;

using day_iter = boost::gregorian::day_iterator;

int main()
{

    int year, month, day;
    cin >> year >> month >> day;
    cout << "You have input flowing: " << "\n" << year << "," << month << "," << day << std::endl;


    date d(year,month,day);

    assert(d.is_special() == false);
    cout << to_iso_extended_string(d) << " is a valid date." << endl << endl;

    date d_start(d.year(), d.month(), 1);
    date d_end(d.end_of_month());

    cout << "Start day is: " << to_iso_extended_string(d_start) << endl;
    cout << "End day is: " << to_iso_extended_string(d_end) << endl;

    cout << endl;

//    前置++运算符重载
//    person& operator ++();
//    后置++运算符重载,注意需要加int来与前置++重载做区分，语法这样规定。
//    person operator ++(int);  //为什么返回值不用引用，因为不可以返回局部变量

    cout << "Month: " << endl;

//    日期迭代器因为性能的原因，仅提供了前置++/--运算符。
    size_t line_counter = 1;
    for(day_iter d_iter(d_start); *d_iter <= d_end; ++d_iter){
        cout << to_iso_extended_string(*d_iter) << " " << d_iter->day_of_week() << "\t";
        if (line_counter % 7 == 0){ cout << endl; }
        line_counter++;
    }

    return 0;
}
